package com.zxx.addressparse;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    TextView textView;
    EditText editText;
    Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = findViewById(R.id.tv_address);
        editText = findViewById(R.id.edit_query);
        button = findViewById(R.id.btn);

        final AddressUtilss utilss = new AddressUtilss(this);

        button.setOnClickListener(new View.OnClickListener() {
            @SuppressLint("SetTextI18n")
            @Override
            public void onClick(View v) {
                String code = editText.getText().toString().trim();
                if (!TextUtils.isEmpty(code)) {
                    String address = utilss.parseCode(code);
                    String address2 = utilss.parseCode2(code);

                    textView.setText(address + "\n\n" + address2);
                }
            }
        });


    }
}
